package scalaLearning.part1

object WordCount2 {
  def main(args: Array[String]): Unit = {
    val arr1: Array[String] = Array("hadoop", "scala", "hadoop", "hive")
    val tuples: Array[(String, Int)] = arr1.map((_, 1))
    val stringToTuples: Map[String, Array[(String, Int)]] = tuples.groupBy(_._1)
    val stringToInt: Map[String, Int] = stringToTuples.map(t => (t._1, t._2.length))
    val reverse: List[(String, Int)] = stringToInt.toList.sortBy(_._2).reverse
    reverse.foreach(println)
  }
}
